#include "thread_pool.h"

void initDirStack(DirStack* s){
    s->front = 0;
    s->node_num = 0;
}

void pushDirStack(DirStack* s, const char* filename){
    DirNode *node = calloc(1, sizeof(DirNode));
    strcpy(node->dirname, filename);
    node->next = s->front;
    s->front = node;
    s->node_num++;
}

void getDirPath(DirStack* s, char* path){
    DirNode* p = s->front;
    if(!p) strcat(path, "/");
    while(p){
        strcat(path, "/");
        strcat(path, p->dirname);
        p = p->next;
    }
}

void destroyDirStack(DirStack* s){
    DirNode* p = s->front;
    while(s->front){
        s->front = s->front->next;
        free(p);
        p = s->front;
    }
}
